﻿#ifndef DBOPERATION_H
#define DBOPERATION_H
#include <QObject>
#include<QtSql/QSql>
#include<QtSql/QSqlQuery>
#include<QStringList>
#include<QtSql/QSqlTableModel>
#include<QList>
#include"Beans/userinfobean.h"
#include"Beans/datainfobean.h"
class DBOperation : public QObject
{
    Q_OBJECT
public:
    explicit DBOperation(QObject *parent = 0);
    ~DBOperation();
    void SetTableName(QString table);
    bool opendatabase();
    bool closedatabase();
    bool CheckDataBase(QString filePath);
    bool QuertUserInfo(QString usName);
    bool QuertUserInfo(QString usName,QString pwd);
    QList<DataInfoBean>QuertAllDataInfo();
    UserInfoBean QueryUserInfoBysql(QString sql);
    QList<UserInfoBean>QuertAllUserInfo();
    bool insert(QString table, QStringList names,QStringList values);
    bool Updata(QString table, QStringList names,QStringList values, QString expression);
    bool del(QString table, QString expression);
    void GetValues(QString &table, QStringList &values);
    QList<DataInfoBean> QueryDataInfoBy(QString expression);
    bool dbOpenSF;//数据库打开成功or失败
private:
    QSqlTableModel *model;
    QSqlDatabase db;
    QString tableName;

};

#endif // DBOPERATION_H
